#include "stdafx.h"

class NewtonListener : public FrameListener
{
public:
    NewtonListener(OgreNewt::World* W)
       
    {
		m_World=W;
		m_update = 1.0/60.0;
		m_elapsed = 0.0f;
    }

    bool frameStarted(const FrameEvent& evt)
    {
		if(1)
		{
		m_elapsed+=evt.timeSinceLastFrame*1.5;

			if ((m_elapsed>m_update)&&(m_elapsed<(1.0)))
			{
				while(m_elapsed>m_update)
				{
					m_World->update(m_update);
					m_elapsed-=m_update;
				}
				
			} else
			{
			if(m_elapsed<m_update)
			{}
			else
			{
			m_World->update(m_elapsed);
		    m_elapsed=0.0f;
			}
		}
        
		}

	return cont;
    }

private:
    OgreNewt::World* m_World;
	Real m_elapsed;
	Real m_update;
};